- /* sxmcvdec.cpp by K.Tsuru */
- // function ID = 503 BRADIX
- /*************************************
- SDecimal class
- radix conversion BRADIX --> DRADIX
- normal method
- **************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SDouble SDecimal::NConvToDec() const{
- if(RawSign() == 0) return 0.0;
- if(aHead == 0){ //integral part only
- SDouble I;
- I = RawSign()*(int)figure(0);
- return I;
- }
- SDouble result(REAL, SNMaxSize(REAL));
- SDecimal a(*this);
- uint rsz = result.Size(), asz =a.Size();
-
- a.SetSign(1);
- fType* av = a.figure.Elements();
- fType* rv = result.figure.Elements();
-
- //Conversion of decimal part
- result.rdxExp = 0;
- uint at, i, rh, rt;
-
- for(i = 1; i < rsz ; i++) {
- av[0] = 0;
- if(!av[a.aTail]){ //Position of "aTail" moved by av[0] = 0 when a.aTail = 0.
- at = a.aTail;
- while(!av[at] && (at < asz)) at++;
- if(at == asz){ // a == 0
- a.aTail = a.aHead = 0; a.SetSign(0); break;
- }
- a.aTail = at;
- }
- XsMult(a, DRADIX, a); //Position of "a.aHead" is decided in XsMult().
- rv[i] = av[0];
- }
- i = min(i, rsz-1);
- while(!rv[i] && (i>0) ) i--;
- rh = i;
- i = 0;
- while(!rv[i] && (i < rh) ) i++;
- rt = i;
-
- result.aTail = rt;
- result.aHead = rh;
- result.SetSign( int(rv[rt]) );
-
- //Add integer part.
- if(figure(0) != 0){
- //Not rv[0] = figure(0) because it is possible figure(0) >= DRADIX.
- result = DDAdd(result, figure(0));
- }
- result.CutDown(result.POP);
- result.Reform(503);
- if(result.Sign(503) != 0) result.SetSign(RawSign());
- return result;
- }
sxmcvdec.cpp : last modifiled at 2017/03/13 14:32:02(1,561 bytes)
created at 2015/12/22 16:09:56
The creation time of this html file is 2017/10/27 15:45:59 (Fri Oct 27 15:45:59 2017).